Skip to content

container: Add export --format=tar command#1969

Draft
cgwalters wants to merge 2 commits intomainfrom
tar-export-work
Draft

container: Add export --format=tar command#1969
cgwalters wants to merge 2 commits intomainfrom
tar-export-work

Conversation

@cgwalters
Copy link
Collaborator

@cgwalters cgwalters commented Feb 2, 2026

This adds bootc container export which is designed for compatibility
with the Anaconda "liveimg" verb:
https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/automatically_installing_rhel/kickstart-commands-and-options-reference_rhel-installer#liveimg_kickstart-commands-for-installation-program-configuration-and-flow-control

Fixes #1957

Assisted-by: OpenCode (Sonnet 4.5)
Signed-off-by: Colin Walters walters@verbum.org

@bootc-bot bootc-bot bot requested a review from jeckersb February 2, 2026 15:42
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new bootc container export --format=tar command, a significant feature for creating bootable tar archives from container filesystems. However, the implementation has critical security issues related to symlink handling and metadata preservation. Specifically, the use of symlink-following metadata calls and ambient directory handles could lead to information disclosure of host files if a malicious container image is exported. Additionally, directory metadata is not correctly preserved, resulting in incorrect permissions in the exported archive. Beyond these security concerns, there are also suggestions to improve performance by avoiding unnecessary memory allocations when adding SELinux attributes in container_export.rs and to refactor duplicated code in the kernel relocation logic for better maintainability.

@github-actions github-actions bot added the area/documentation Updates to the documentation label Feb 2, 2026
@cgwalters cgwalters force-pushed the tar-export-work branch 2 times, most recently from bec071b to 46b0bac Compare February 3, 2026 16:34
Some people want to use container build tools, but for compatibility
with older systems export a tar format of the OS state e.g.
Anaconda liveimg expects this.

Basically this is only *slightly* more than just `tar cf`; we need
to handle SELinux labeling and move the kernel.

Ref: #1957

Assisted-by: OpenCode (Sonnet 4.5)
Signed-off-by: Colin Walters <walters@verbum.org>
Add 'cargo xtask anaconda' command that validates bootc containers can
be installed via Anaconda's liveimg kickstart directive. This is an
end-to-end integration test that:

- Exports a bootc container to tar format using 'bootc container export'
- Downloads and caches Anaconda installer ISOs (CentOS Stream 10, Fedora)
- Generates kickstart files with liveimg --url=file:// directive
- Uses virtiofs to share the tar with the VM (avoids HTTP server complexity)
- Boots VM in UEFI mode with proper BLS boot entry generation
- Monitors installation via Anaconda's virtio serial progress channel
- Verifies installation using bcvk (disk inspection) and optionally SSH

The test handles several tricky aspects of bootc + Anaconda integration:

1. BLS entry generation: bootc tar exports don't include Boot Loader
   Specification entries (they need root partition UUID). We generate
   these in the kickstart %post script.

2. SSH in chroot: The %post script runs in a chroot where services
   can't be started, only enabled. We configure sshd to start on
   first boot rather than trying to start it during installation.

3. Bootloader installation: Uses bootupctl to install the bootloader
   in the Anaconda %post environment.

Usage:
  cargo xtask anaconda [--ssh] [--installer-type=centos-stream-10] \
    <container-image> <output-disk>

Assisted-by: OpenCode (Claude Sonnet 4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation Updates to the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add bootc container export --format=tar

1 participant